target_info: TargetInfo,
host_info: TargetInfo,
profiles: &'a Profiles,
+ incremental_enabled: bool,
}
#[derive(Clone, Default)]
None => None,
};
+ // Enable incremental builds if the user opts in. For now,
+ // this is an environment variable until things stabilize a
+ // bit more.
+ let incremental_enabled = env::var("CARGO_INCREMENTAL").is_ok();
+
Ok(Context {
ws: ws,
host: host_layout,
build_explicit_deps: HashMap::new(),
links: Links::new(),
used_in_plugin: HashSet::new(),
+ incremental_enabled: incremental_enabled,
})
}
self.lib_profile()
}
+ pub fn incremental_args(&self, _unit: &Unit) -> CargoResult<Vec<String>> {
+ if self.incremental_enabled {
+ Ok(vec![format!("-Zincremental={}", self.host.incremental().display())])
+ } else {
+ Ok(vec![])
+ }
+ }
+
pub fn rustflags_args(&self, unit: &Unit) -> CargoResult<Vec<String>> {
env_args(self.config, &self.build_config, unit.kind, "RUSTFLAGS")
}
//! $pkg2/
//! $pkg3/
//!
+//! # Directory used to store incremental data for the compiler (when
+//! # incremental is enabled.
+//! incremental/
+//!
//! # Hidden directory that holds all of the fingerprint files for all
//! # packages
//! .fingerprint/
deps: PathBuf,
native: PathBuf,
build: PathBuf,
+ incremental: PathBuf,
fingerprint: PathBuf,
examples: PathBuf,
_lock: FileLock,
deps: root.join("deps"),
native: root.join("native"),
build: root.join("build"),
+ incremental: root.join("incremental"),
fingerprint: root.join(".fingerprint"),
examples: root.join("examples"),
root: root,
mkdir(&self.deps)?;
mkdir(&self.native)?;
+ mkdir(&self.incremental)?;
mkdir(&self.fingerprint)?;
mkdir(&self.examples)?;
mkdir(&self.build)?;
pub fn deps(&self) -> &Path { &self.deps }
pub fn examples(&self) -> &Path { &self.examples }
pub fn root(&self) -> &Path { &self.root }
+ pub fn incremental(&self) -> &Path { &self.incremental }
pub fn fingerprint(&self) -> &Path { &self.fingerprint }
pub fn build(&self) -> &Path { &self.build }
}
let dep_info_loc = fingerprint::dep_info_loc(cx, unit);
let cwd = cx.config.cwd().to_path_buf();
+ rustc.args(&cx.incremental_args(unit)?);
rustc.args(&cx.rustflags_args(unit)?);
let json_messages = cx.build_config.json_messages;
let package_id = unit.pkg.package_id().clone();
execs().with_status(0).with_stdout("i am foo\n"));
}
+/// Check that the `CARGO_INCREMENTAL` environment variable results in
+/// `rustc` getting `-Zincremental` passed to it.
+#[test]
+fn cargo_compile_incremental() {
+ if !is_nightly() {
+ return
+ }
+
+ let p = project("foo")
+ .file("Cargo.toml", &basic_bin_manifest("foo"))
+ .file("src/foo.rs", &main_file(r#""i am foo""#, &[]));
+
+ assert_that(
+ p.cargo_process("build").arg("-v").env("CARGO_INCREMENTAL", "1"),
+ execs().with_stderr_contains(
+ " Running `rustc [..] -Zincremental=[..]/target/debug/incremental`\n"));
+}
+
#[test]
fn cargo_compile_manifest_path() {
let p = project("foo")